#include <stdio.h>
#include <sys/stat.h>
#include <time.h>

int main( int argc, const char* argv[] )
{
	if(argc < 2) {
		printf("usage: status source_path\n");
		return;
	}
	// Get info about file.
	const char *source = argv[1];
	struct stat status;
	stat(source, &status);
	
	printf("  File: \"%s\"\n", source);
	printf("  Size: %ld\n", status.st_size);
	printf("Access: %o \n", status.st_mode & ~S_IFMT);
	
	printf("  Type: ");
	int type = status.st_mode & S_IFMT;
   	switch (type) {
     	case S_IFREG: printf("file\n"); break;
     	case S_IFLNK: printf("symbolic link\n"); break;
     	case S_IFDIR: printf("folder\n"); break;
     	default: printf("other\n");
   	}
   	
   	printf("  User: %i\n", status.st_uid);
   	printf(" Group: %i\n", status.st_gid);
   	
   	struct tm *lastChange = localtime(&status.st_mtime);
   	char buf[80];
   	strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", lastChange);
    printf("Modify: %s\n", buf);
}
